<template>
  <div>
    <ElDrawer v-model="visible"
      ><ElForm style="width: 300px">
        <ElFormItem label="申请部门">
          <ElSelect v-model="subexpmodifyDto.department">
            <ElOption label="销售部" value="sale"></ElOption>
            <ElOption label="财务部" value="finance"></ElOption>
            <ElOption label="市场部" value="duration"></ElOption>
          </ElSelect>
        </ElFormItem>
        <ElFormItem label="申请金额">
          <el-input-number v-model="subexpmodifyDto.money" />
        </ElFormItem>
        <ElFormItem label="用途">
          <ElInput type="textarea" v-model="subexpmodifyDto.useto" />
        </ElFormItem>
        <ElButton type="primary" @click="modify()">确定</ElButton>
      </ElForm></ElDrawer
    >
  </div>
</template>
<script lang="ts">

/**
 * 页面核心数据结构体说明文档
 *
 *
 */
// import from
export type departments = 'sale' | 'finance' | 'duration'
export default {
  name: 'SubEponseInsert',
  props: {
    sampleP: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      sampleD: 'value',
      visible: false,
      subexpmodifyDto: {
        department: 'sale' as departments,
        useto: '' as String,
        money: 0 as number
      },
      modifycode:''
    }
  },
  computed: {
    /* sampleC() {
      return this.sampleD + "--";
    }, */
  },
  created() {},
  mounted() {},
  methods: {
    // sampleM() {},
  async modify(){
    console.log(this.modifycode)
    console.log(this.subexpmodifyDto)
     await axios({
            method: "PUT",
            url: "http://127.0.0.1:7001/subexponse/modify/applier/"+this.modifycode,
            data:this.subexpmodifyDto
          }).then(
            (res) => {
              this.visible=false;
              ElMessage.success('报销申请修改成功')
              ElMessage.success('修改时间:'+this.time(new Date(res.data.applytime)))
              this.$emit('putmodify')
            },
            (error) => {
              console.log(error.response.data);
              ElMessage.success(error.response.data)
            }
          );
   },
     time(date: Date) {
         const datec =
           date.getFullYear() +
           '年' +
           (date.getMonth() + 1) +
           '月' +
           date.getDate() +
           '日' +
           date.getHours() +
           '时' +
           date.getMinutes()+
           '分'+
           date.getSeconds()+
           '秒'
         //用法
         // <ElTableColumn> <template #default="{ row }">
         //     <span>{{ time(new Date(row.applytime)) }}</span>
         //   </template></ElTableColumn>
         return datec
       }
  },
  watch: {
    // sampleP(n, o) {},
  }
}
</script>

<!--<style scoped>-->
<style lang="scss" scoped></style>
